#include <bits/stdc++.h>
// 2025/05/17
// tag: LCA
// Author: Forever
using namespace std;
using int64 = int64_t;

#define MAXN 100001
#define LOG_MAX 20

int n, k;
vector<int> tree[MAXN];

int up[MAXN][LOG_MAX];
int depth[MAXN], ans[MAXN];

void preprocess(int u, int parent)
{
    up[u][0] = parent;
    for (int k = 1; k < LOG_MAX; ++k)
        up[u][k] = up[up[u][k - 1]][k - 1];
    for (int v : tree[u]) {
        if (v != parent) {
            depth[v] = depth[u] + 1;
            preprocess(v, u);
        }
    }
}

int lca(int u, int v)
{
    if (depth[u] < depth[v])
        swap(u, v);
    for (int k = LOG_MAX - 1; k >= 0; --k)
        if (depth[u] - (1 << k) >= depth[v])
            u = up[u][k];
    if (u == v)
        return u;
    for (int k = LOG_MAX - 1; k >= 0; --k)
        if (up[u][k] != up[v][k])
            u = up[u][k], v = up[v][k];
    return up[u][0];
}

int dist(int u, int v)
{
    return depth[u] + depth[v] - 2 * depth[lca(u, v)];
}

void dfs(int u, int parent)
{
    for (int v : tree[u]) {
        if (v != parent) {
            dfs(v, u);
            ans[u] += ans[v];
        }
    }
}

int main()
{
    cin >> n >> k;
    for (int i = 1; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }
    preprocess(1, 1);
    for (int i = 1; i <= k; ++i) {
        int s, t, l;
        cin >> s >> t;
        l = lca(s, t);
        ans[s]++, ans[t]++, ans[l]--, ans[up[l][0]]--;
    }
    dfs(1, 1);
    int maxans = 0;
    for (int i = 1; i <= n; ++i)
        maxans = max(maxans, ans[i]);
    cout << maxans << endl;
    return 0;
}